﻿using System.Collections;
using System.Collections.Generic;

namespace ControleRepresentante.Logic.Models
{
    public class CompareYear : IEnumerable<double>
    {
        private readonly Dictionary<int, double> m_Totals;
 
        public int Year { get; private set; }

        public CompareYear(int year)
        {
            Year = year;
            m_Totals = new Dictionary<int, double>();
        }

        public void AddMonth(int month, double total)
        {
            m_Totals[month] = total;
        }

        public double? this[int month]
        {
            get
            {
                double total;
                if (m_Totals.TryGetValue(month, out total))
                {
                    return total;
                }
                return null;
            }
        }

        public IEnumerator<double> GetEnumerator()
        {
            return m_Totals.Values.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}
